'use strict';

module.exports = app => {
    class HomeworkController extends app.Controller {

        //作业管理列表
        async homework(){
            const data = await this.service.homework.getJobAccounting();
            await this.ctx.render("/homework/homework.html",{data});
        };

        //作业报告
        async homeworkdetail(){
            const params = this.ctx.request.query;
            const data = await this.service.homework.getJobDetaile(params);
            await this.ctx.render("/homework/jobmanagement/homework-detail.html",{data});
        };

        //作业报告内的作业详情
        async homeworkdetails(){
            const params = this.ctx.request.query;
            const data = await this.service.homework.getTeacherQuestion(params);
            await this.ctx.render("/homework/jobmanagement/homework-details.html",{data});
        }

        //作业完成情况
        async complete(){
            const params = this.ctx.request.query;
            const data = await this.service.homework.getStudentTask(params);
            const undata = await this.service.homework.unfinished(params);
            await this.ctx.render("/homework/jobmanagement/complete.html",{data,undata});
        }

        //作业完成详情
        async completedetail(){
            const params = this.ctx.request.query;
            const data = await this.service.homework.getStudentReport(params);
            await this.ctx.render("/homework/jobmanagement/complete-detail.html",{data});
        }






        /*
        布置作业
         */

        //布置作业方式
        async arrhomework(){
            await this.ctx.render("/homework/arr-homework.html");
        }

        //统一出题-选择教材版本
        async version(){
            const data = await this.service.homework.getTeacherPress();
            await this.ctx.render("/homework/version.html",{data});
        }

        //统一出题-选择班级
        async arrhomework1(){
            const data = await this.service.homework.getTeacherClazz();
            await this.ctx.render("/homework/arr-homework1.html",{data});
        }

        //一对一出题-选择班级
        async otohomework1(){
            const data = await this.service.class.getClass();
            await this.ctx.render("/homework/oto-homework1.html",{data});
        }
        //一对一出题-选择学生
        async otohomework2(){
            const params = this.ctx.request.query;
            const data = await this.service.class.getStudentList(params)
            await this.ctx.render("/homework/oto-homework2.html",{data});
        }

        //统一出题-选择知识点
        async arrhomework2(){
            const params = this.ctx.request.query;
            const data = await this.service.homework.getTeacherPress(params);
            const list = await this.service.homework.getPointList(data);
            await this.ctx.render("/homework/arr-homework2.html",{data,list});
        }

        //统一出题-选择题目
        async arrhomework3(){
            const params = this.ctx.request.query;
            const data = await this.service.homework.getQuestionlist(params);
            await this.ctx.render("/homework/arr-homework3.html",{data});
        }

        //统一出题-题目解析
        async arrhomework4(){
            const params = this.ctx.request.query;
            const data = await this.service.homework.getTeacheranalyze(params);
            await this.ctx.render("/homework/arr-homework4.html",{data});
        }

        //统一出题-已选题目
        async selected(){
            const params = this.ctx.request.query;
            const data = await this.service.homework.getQuestionlist(params);
            await this.ctx.render("/homework/homework-selected.html",{data});
        }

        //统一出题-发布作业
        async release(){
            if('GET' == this.ctx.request.method)
            {
                await this.ctx.render("/homework/release.html");
            }else{
                const params = this.ctx.request.body;
                const data = await this.service.homework.publishjob(params);
                this.success();
            }

        }

    }
    return HomeworkController;
};

